//
//  DaumMapParser.h
//  Tag-C
//
//  Created by KyuJin on 13. 2. 9..
//  Copyright (c) 2013년 monscape. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <DaumMap/MTMapView.h>
#import <DaumMap/MTMapPOIItem.h>
#import <DaumMap/MTMapReverseGeoCoder.h>
#import "ManagementClass.h"
#import "XMLParser.h"

#define CONVERT_URL @"http://apis.daum.net/local/geo/transcoord?apikey=28d690834d271b468a59a0dced646c3dd62466ce&x=%f&y=%f&fromCoord=KTM&toCoord=WCONGNAMul"
#define TRADE_URL @"http://openapi.naver.com/search?key=43d37f55b17c7e928f768fa61c8e7eb2&query=%@&target=local&start=1&display=10"
#define ADDRESS_URL @"http://openapi.map.naver.com/api/geocode.php?key=b2bf09c13860051d2b151b5b0689dad2&encoding=utf-8&coord=tm128&query=%@"
#define ROUTE_SEARCH_URL @"http://map.daum.net/route/route.json?callback=jQuery18105068596978671849_1358838674186&carMode=SHORTEST_REALTIME&carOption=NONE&walkMode=RECOMMENDATION&walkOption=NONE&sName=%@&sX=%f&sY=%f&eName=%@&eX=%f&eY=%f"

typedef enum{
    SEARCH_TYPE_TRADE,
    SEARCH_TYPE_ADDRESS
}SEARCH_TYPE;

@interface DaumMapParser : NSObject

// Singleton Function
+ (DaumMapParser*) getInstance;

// Getter Function
- (MTMapPointPlain) getCoodFromTradeName:(NSString*)location;
- (MTMapPointPlain) getCoodFromAddress:(NSString*)location;
- (TreeNode*) getTradeSearchResult:(NSString*)location;
- (TreeNode*) getAddressSearchResult:(NSString*)location;
- (NSString*) getRouteJsonString:(NSString*)startName eName:(NSString*)endName sPoint:(MTMapPointPlain)startPoint ePoint:(MTMapPointPlain)endPoint;
- (NSInteger) getTaxiCost:(NSDictionary*)jsonData;
- (NSInteger) getExpectedTime:(NSDictionary*)jsonData;
- (double) getDistance:(NSDictionary*)jsonData;

// Data Function
- (NSDictionary*) parseMapJsonData:(NSString*)jsonString;
- (NSArray*) parseSearchXmlData:(NSString*)xmlData searchType:(SEARCH_TYPE)type;
- (MTMapPointPlain) convertKTMtoWCONG:(MTMapPointPlain)cood;

// Map Control Function
- (void) addRoutePolyLine:(MTMapView*)mapView json:(NSDictionary*)jsonData;
- (void) addStartPOIItem:(MTMapView*)mapView point:(MTMapPointPlain)startPoint;
- (void) addEndPOIItem:(MTMapView*)mapView point:(MTMapPointPlain)endPoint;

@end
